package com.cc.service.impl;

import com.cc.com.Page;
import com.cc.entity.Book;
import com.cc.mapper.BookMapper;
import com.cc.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author yuton
* @description 针对表【book】的数据库操作Service实现
* @createDate 2025-09-01 14:49:29
*/
@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookMapper bookMapper;

    @Override
    public Page<Book> getBookPage(String bookName, String author, Integer pageNum, Integer pageSize) {
        Page<Book> page = new Page<>();
        page.setPageNum(pageNum);
        page.setPageSize(pageSize);
        List<Book> bookList = bookMapper.getBookListPage(bookName, author, pageNum, pageSize);
        Integer totalCount = bookMapper.getBookListTotalCount(bookName, author);
        page.setData(bookList);
        page.setTotalCount(totalCount);
        return   page;
    }
}
